package correct.day26;

import java.util.Scanner;

public class Test2 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int[] arr = new int[n + 1];
        int[] f = new int[n + 1];
        int[] g = new int[n + 1];
        for(int i = 1; i <= n; i++)
        {
            arr[i] = in.nextInt();
        }
        for(int i = 1; i <= n; i++)
        {
            f[i] = g[i - 1] + arr[i];
            g[i] = Math.max(f[i - 1], g[i - 1]);
        }
        System.out.println(Math.max(f[n], g[n]));
    }
}
